Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unist-util-visit-parents

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-visit-parents

unist utility to recursively walk over nodes, with ancestral information

  • 3.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is unist-util-visit-parents?

The unist-util-visit-parents package is a utility for traversing Unist syntax trees. It allows for visiting nodes, optionally filtered by type, and provides access to parent nodes during traversal. This can be particularly useful for manipulating or inspecting the structure of documents parsed into Unist syntax trees, such as Markdown or HTML parsed by remark or rehype processors.

What are unist-util-visit-parents's main functionalities?

Visiting nodes with access to their parents

This feature allows you to visit all nodes of a specified type ('paragraph' in this example) in a Unist syntax tree, and for each node, you have access to an array of its ancestor nodes. This is useful for context-aware processing or transformations.

visit(tree, 'paragraph', (node, ancestors) => {
  console.log(node);
  console.log(ancestors);
});

Visiting all nodes without filtering

This feature enables visiting all nodes in the syntax tree without filtering by type. Each visited node is accompanied by its ancestors, allowing for comprehensive traversal and manipulation of the tree.

visit(tree, (node, ancestors) => {
  console.log(node);
  console.log(ancestors);
});

Other packages similar to unist-util-visit-parents

Keywords

FAQs

Package last updated on 19 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc